 //获取dom元素
 
 let info = document.querySelector("main>.info")
 let nav_four = document.querySelector("nav>a:nth-child(3)")
 let comment = document.querySelector(".comment>.allcontent")



 //获取productId
 let productid = getQueryString('productid')

 reqInfo(productid)


 /* 获取商品的信息和评论 */
 function reqInfo(productid) {
     fetch("http://chst.vip:1234/api/getproduct?productid=" + productid)
         .then(response => response.json())
         .then(res => {
             // console.log(res.result[0].bjShop);
             //商品的名称
             let name = res.result[0].productName.split(" ")[0]
             let domStr = `
         <div class="pic">
             ${res.result[0].productImg}
         </div>
         <div class="title">
             ${res.result[0].productName}
         </div>
         <div class="count">
             <div class="left">
                 <span>当前最低</span>
                 <span>￥6000</span>
             </div>
             <div class="right">
                 <span>优选评论</span>
                 <span>8266条</span>
             </div>

         </div>
         <div class="makeprice">
             <table width="100%">
                 <tbody>
                     <tr>
                         <td rowspan="2" class="p_pic" valign="top">
                             <a href="redirect.aspx?webid=1&amp;bjid=76069915&amp;tourl=http://item.jd.com/1162187.html&amp;y=bijia"
                                 target="_blank" onclick="trackLog('商品购买','比价页面');">
                                 <img src="http://sf.manmanbuy.com/images/sitelogo/1.png"></a>
                         </td>
                         <td> <a href="redirect.aspx?webid=1&amp;bjid=76069915&amp;tourl=http://item.jd.com/1162187.html&amp;y=bijia"
                                 target="_blank" onclick="trackLog('商品购买','比价页面');">京东商城</a> </td>
                         <td class="red"> ￥1999.00 </td>
                         <td align="center" width="60"> <span
                                 style="display: inline-block;width: 56px;height: 24px;border-radius: 6px;text-align: center;line-height: 24px;background-color: #ff5500;color: #fff;font-size: 14px;">去购买</span>
                         </td>
                     </tr>
                     <tr class="tab2">
                         <td> </td>
                         <td class="r"> </td>
                         <td></td>
                     </tr>
                 </tbody>
             </table>
         </div>`
             info.innerHTML = domStr;
             //标签链接
             nav_four.innerHTML = name
         })

     fetch("http://chst.vip:1234/api/getproductcom?productid=" + productid)
         .then(response => response.json())
         .then(res => {
             console.log(res.result);
             let domStr = ''
             res.result.forEach(item => {
                 domStr += `
             <div class="content clearfix">
                 <div class="up clearfix">
                     <span class="id fl">${item.comName}</span>
                     <span class="time fr">${item.comTime}</span>
                 </div>
                 <div class="content_in">
                     ${item.comContent}
                 </div>
                 <div class="form fr">
                     <span>${item.comFrom}</span>
                 </div>
             </div>`
             })
             comment.innerHTML = domStr;
         })
 }